# -*- coding: utf-8 -*-
# @Time    : 2021/12/9 18:23
# @Author  : TangDagui
# @Email   : 3297364807@qq.com
# @File    : __init__.py.py
# @Software: PyCharm
import sys

from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import tkinter
from tkinter import ttk

window = tkinter.Tk()
# 实例化控件，设置表头样式和标题文本
columns = ("name", "tel", "email", "company")
headers = ("姓名", "电话", "邮箱", "公司")
widthes = (120, 120, 250, 250)
tv = ttk.Treeview(window, show="headings", columns=columns)
def inser_data():
    """插入数据"""
    contacts =[
        ('张三', '1870591xxxx', 'zhang@qq.com', '腾讯'),
        ('李斯', '1589928xxxx', 'lisi@google.com', '谷歌'),
        ('王武', '1340752xxxx', 'wangwu@baidu.com', '微软'),
        ('麻溜儿', '1361601xxxx', 'maliur@alibaba.com', '阿里'),
        ('郑和', '1899986xxxx', 'zhenghe@163.com', '网易'),
    ]
    for i, person in enumerate(contacts):
        tv.insert('', i, values=person)

class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowTitle('主界面')
        self.showMaximized()


class logindialog(QDialog):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)


        self.setWindowTitle('登录界面')
        self.resize(500, 500)
        self.setFixedSize(self.width(), self.height())
        self.setWindowFlags(Qt.WindowCloseButtonHint)

        ###### 设置界面控件
        self.frame = QFrame(self)
        self.verticalLayout = QVBoxLayout(self.frame)


        self.lineEdit_account = QLineEdit()

        self.lineEdit_account.setPlaceholderText("请输入账号")
        self.verticalLayout.addWidget(self.lineEdit_account)



        self.lineEdit_password = QLineEdit()
        self.lineEdit_password.setPlaceholderText("请输入密码")
        self.verticalLayout.addWidget(self.lineEdit_password)

        self.pushButton_enter = QPushButton()
        self.pushButton_enter.setText("确定")

        self.verticalLayout.addWidget(self.pushButton_enter)

        self.pushButton_quit = QPushButton()
        self.pushButton_quit.setText("取消")
        self.verticalLayout.addWidget(self.pushButton_quit)

        ###### 绑定按钮事件
        self.pushButton_enter.clicked.connect(self.on_pushButton_enter_clicked)
        self.pushButton_quit.clicked.connect(QCoreApplication.instance().quit)

    def on_pushButton_enter_clicked(self):
        # 账号判断
        if self.lineEdit_account.text() == "":
            return

        # 密码判断
        if self.lineEdit_password.text() == "":
            return

        # 通过验证，关闭对话框并返回1
        self.accept()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    dialog = logindialog()
    if dialog.exec_() == QDialog.Accepted:
        tv.pack()

        inser_data()

        window.mainloop()


        # the_window = MainWindow()
        # the_window.show()
        # sys.exit(app.exec_())
